package com.salton123.soulove.biz_bmob.aty

import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.salton123.soulove.biz_bmob.helper.BmobHelper
import com.salton123.soulove.biz_bmob.R
import com.salton123.soulove.common.Constants
import com.salton123.ui.base.BaseActivity
import kotlinx.android.synthetic.main.login_form.*
import kotlinx.android.synthetic.main.login_main.btnLogin

/**
 * @Time:2021/2/3 15:51
 * @Author:wujinsheng
 * @Description:
 */
@Route(path = Constants.Router.Bmob.LOGIN)
class LoginAcitivity : BaseActivity() {
    override fun initViewAndData(savedInstanceState: Bundle?) {
        setListener(btnLogin)
    }

    override fun getLayoutId(): Int = R.layout.login_form

    override fun onClick(v: View?) {
        super.onClick(v)
        when (v) {
            btnLogin -> {
                val etUserName = etUserName.text.toString()
                val etPassword = etPassword.text.toString()
                BmobHelper.login(etUserName, etPassword).subscribe({
                    var path = Constants.Router.Apk.MAIN
                    ARouter.getInstance()
                        .build(path)
                        .navigation(activity())
                }, {
                    shortToast("登录失败")
                })
            }
        }
    }
}